home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qlcdnumber.h.z / qlcdnumber.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  2.9 KB  |  110 lines

  1. /****************************************************************************
  2. ** $Id: qlcdnumber.h,v 2.9 1998/07/03 00:09:49 hanord Exp $
  3. **
  4. ** Definition of QLCDNumber class
  5. **
  6. ** Created : 940518
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23.  
  24. #ifndef QLCDNUMBER_H
  25. #define QLCDNUMBER_H
  26.  
  27. #ifndef QT_H
  28. #include "qframe.h"
  29. #include "qbitarray.h"
  30. #endif // QT_H
  31.  
  32.  
  33. class QLCDNumber : public QFrame        // LCD number widget
  34. {
  35.     Q_OBJECT
  36. public:
  37.     QLCDNumber( QWidget *parent=0, const char *name=0 );
  38.     QLCDNumber( uint numDigits, QWidget *parent=0, const char *name=0 );
  39.    ~QLCDNumber();
  40.  
  41.     enum Mode { HEX, DEC, OCT, BIN };
  42.     enum SegmentStyle { Outline, Filled, Flat };
  43.  
  44.     bool    smallDecimalPoint() const;
  45.  
  46.     int        numDigits() const;
  47.     void    setNumDigits( int nDigits );
  48.  
  49.     bool    checkOverflow( double num ) const;
  50.     bool    checkOverflow( int      num ) const;
  51.  
  52.     Mode mode() const;
  53.     void    setMode( Mode );
  54.  
  55.     SegmentStyle segmentStyle() const;
  56.     void    setSegmentStyle( SegmentStyle );
  57.  
  58.     double  value() const;
  59.     int        intValue() const;
  60.     
  61.     QSize sizeHint() const;
  62.  
  63. public slots:
  64.     void    display( int num );
  65.     void    display( double num );
  66.     void    display( const char *str );
  67.     void    setHexMode();
  68.     void    setDecMode();
  69.     void    setOctMode();
  70.     void    setBinMode();
  71.     void    setSmallDecimalPoint( bool );
  72.  
  73. signals:
  74.     void    overflow();
  75.  
  76. protected:
  77.     void    resizeEvent( QResizeEvent * );
  78.     void    drawContents( QPainter * );
  79.  
  80. private:
  81.     void    init();
  82.     void    internalDisplay( const char * );
  83.     void    drawString( const char *, QPainter &, QBitArray * = 0,
  84.             bool = TRUE );
  85.     void    drawDigit( const QPoint &, QPainter &, int, char, char = ' ' );
  86.     void    drawSegment( const QPoint &, char, QPainter &, int, bool = FALSE );
  87.  
  88.     int        ndigits;
  89.     double  val;
  90.     uint    base    : 2;
  91.     uint    smallPoint    : 1;
  92.     uint    fill    : 1;
  93.     uint    shadow    : 1;
  94.     QString digitStr;
  95.     QBitArray points;
  96.  
  97. private:    // Disabled copy constructor and operator=
  98.     QLCDNumber( const QLCDNumber & );
  99.     QLCDNumber &operator=( const QLCDNumber & );
  100. };
  101.  
  102. inline bool QLCDNumber::smallDecimalPoint() const
  103. { return (bool)smallPoint; }
  104.  
  105. inline int QLCDNumber::numDigits() const
  106. { return ndigits; }
  107.  
  108.  
  109. #endif // QLCDNUMBER_H
  110.